package com.ssish.saas.eccs.mapper;

import com.ssish.saas.eccs.model.Card;
import com.ssish.saas.eccs.model.CardExample;
import com.ssish.saas.eccs.model.CardKey;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface CardMapper {
    long countByExample(CardExample example);

    int deleteByExample(CardExample example);

    @Delete({
        "delete from CARD",
        "where CARD_NO = #{cardNo,jdbcType=DECIMAL}",
          "and RECORD_TYPE = #{recordType,jdbcType=CHAR}"
    })
    int deleteByPrimaryKey(CardKey key);

    @Insert({
        "insert into CARD (CARD_NO, RECORD_TYPE, ",
        "BATCH_NO, PINCODE, ",
        "USER_CODE, STATUS, AMOUNT_PAID, ",
        "DATE_PAID, EXPIRY_DATE, ",
        "SUBSCRIBER_ACCT_NO, TYPE_OF_ACCOUNT, ",
        "TYPE_OF_CREDIT_CARD, USAGE, ",
        "ACTIVE_FLAG, CARD_NO_BIN, ",
        "CARD_NO_PAYOR_ID, CARD_NO_PIS, ",
        "CARD_NO_SEQ, CREDIT_CARD_BIN, ",
        "CREDIT_CARD_NO, CREDIT_CARD_NO_SEQ, ",
        "DEPENDENT_ID, EXPIRY_MONTH, ",
        "EXPIRY_YEAR, ISSUED_DATE, ",
        "MEMBER_ID, MODIFIED_DATE, ",
        "MODIFIED_TIME, PAYOR_CODE, ",
        "POLICY_NO, NEW_IC, ",
        "EMP_NAME, DATE_OF_BIRTH, ",
        "GENDER, CORP_CODE, CHIP_LASTUPD, ",
        "PLAN_CODE, ENGLISH_NAME, ",
        "CARD_TYPE, MASTER_POLICY_NO, ",
        "MEMBER_CONTROL_NO)",
        "values (#{cardNo,jdbcType=DECIMAL}, #{recordType,jdbcType=CHAR}, ",
        "#{batchNo,jdbcType=DECIMAL}, #{pincode,jdbcType=DECIMAL}, ",
        "#{userCode,jdbcType=VARCHAR}, #{status,jdbcType=CHAR}, #{amountPaid,jdbcType=DECIMAL}, ",
        "#{datePaid,jdbcType=TIMESTAMP}, #{expiryDate,jdbcType=TIMESTAMP}, ",
        "#{subscriberAcctNo,jdbcType=CHAR}, #{typeOfAccount,jdbcType=DECIMAL}, ",
        "#{typeOfCreditCard,jdbcType=DECIMAL}, #{usage,jdbcType=DECIMAL}, ",
        "#{activeFlag,jdbcType=CHAR}, #{cardNoBin,jdbcType=DECIMAL}, ",
        "#{cardNoPayorId,jdbcType=DECIMAL}, #{cardNoPis,jdbcType=CHAR}, ",
        "#{cardNoSeq,jdbcType=DECIMAL}, #{creditCardBin,jdbcType=DECIMAL}, ",
        "#{creditCardNo,jdbcType=CHAR}, #{creditCardNoSeq,jdbcType=DECIMAL}, ",
        "#{dependentId,jdbcType=CHAR}, #{expiryMonth,jdbcType=CHAR}, ",
        "#{expiryYear,jdbcType=CHAR}, #{issuedDate,jdbcType=TIMESTAMP}, ",
        "#{memberId,jdbcType=CHAR}, #{modifiedDate,jdbcType=OTHER}, ",
        "#{modifiedTime,jdbcType=CHAR}, #{payorCode,jdbcType=CHAR}, ",
        "#{policyNo,jdbcType=VARCHAR}, #{newIc,jdbcType=VARCHAR}, ",
        "#{empName,jdbcType=VARCHAR}, #{dateOfBirth,jdbcType=TIMESTAMP}, ",
        "#{gender,jdbcType=CHAR}, #{corpCode,jdbcType=VARCHAR}, #{chipLastupd,jdbcType=TIMESTAMP}, ",
        "#{planCode,jdbcType=VARCHAR}, #{englishName,jdbcType=VARCHAR}, ",
        "#{cardType,jdbcType=CHAR}, #{masterPolicyNo,jdbcType=VARCHAR}, ",
        "#{memberControlNo,jdbcType=VARCHAR})"
    })
    int insert(Card record);

    int insertSelective(Card record);

    List<Card> selectByExample(CardExample example);

    @Select({
        "select",
        "CARD_NO, RECORD_TYPE, BATCH_NO, PINCODE, USER_CODE, STATUS, AMOUNT_PAID, DATE_PAID, ",
        "EXPIRY_DATE, SUBSCRIBER_ACCT_NO, TYPE_OF_ACCOUNT, TYPE_OF_CREDIT_CARD, USAGE, ",
        "ACTIVE_FLAG, CARD_NO_BIN, CARD_NO_PAYOR_ID, CARD_NO_PIS, CARD_NO_SEQ, CREDIT_CARD_BIN, ",
        "CREDIT_CARD_NO, CREDIT_CARD_NO_SEQ, DEPENDENT_ID, EXPIRY_MONTH, EXPIRY_YEAR, ",
        "ISSUED_DATE, MEMBER_ID, MODIFIED_DATE, MODIFIED_TIME, PAYOR_CODE, POLICY_NO, ",
        "NEW_IC, EMP_NAME, DATE_OF_BIRTH, GENDER, CORP_CODE, CHIP_LASTUPD, PLAN_CODE, ",
        "ENGLISH_NAME, CARD_TYPE, MASTER_POLICY_NO, MEMBER_CONTROL_NO",
        "from CARD",
        "where CARD_NO = #{cardNo,jdbcType=DECIMAL}",
          "and RECORD_TYPE = #{recordType,jdbcType=CHAR}"
    })
    @ResultMap("com.ssish.saas.eccs.mapper.CardMapper.BaseResultMap")
    Card selectByPrimaryKey(CardKey key);

    int updateByExampleSelective(@Param("record") Card record, @Param("example") CardExample example);

    int updateByExample(@Param("record") Card record, @Param("example") CardExample example);

    int updateByPrimaryKeySelective(Card record);

    @Update({
        "update CARD",
        "set BATCH_NO = #{batchNo,jdbcType=DECIMAL},",
          "PINCODE = #{pincode,jdbcType=DECIMAL},",
          "USER_CODE = #{userCode,jdbcType=VARCHAR},",
          "STATUS = #{status,jdbcType=CHAR},",
          "AMOUNT_PAID = #{amountPaid,jdbcType=DECIMAL},",
          "DATE_PAID = #{datePaid,jdbcType=TIMESTAMP},",
          "EXPIRY_DATE = #{expiryDate,jdbcType=TIMESTAMP},",
          "SUBSCRIBER_ACCT_NO = #{subscriberAcctNo,jdbcType=CHAR},",
          "TYPE_OF_ACCOUNT = #{typeOfAccount,jdbcType=DECIMAL},",
          "TYPE_OF_CREDIT_CARD = #{typeOfCreditCard,jdbcType=DECIMAL},",
          "USAGE = #{usage,jdbcType=DECIMAL},",
          "ACTIVE_FLAG = #{activeFlag,jdbcType=CHAR},",
          "CARD_NO_BIN = #{cardNoBin,jdbcType=DECIMAL},",
          "CARD_NO_PAYOR_ID = #{cardNoPayorId,jdbcType=DECIMAL},",
          "CARD_NO_PIS = #{cardNoPis,jdbcType=CHAR},",
          "CARD_NO_SEQ = #{cardNoSeq,jdbcType=DECIMAL},",
          "CREDIT_CARD_BIN = #{creditCardBin,jdbcType=DECIMAL},",
          "CREDIT_CARD_NO = #{creditCardNo,jdbcType=CHAR},",
          "CREDIT_CARD_NO_SEQ = #{creditCardNoSeq,jdbcType=DECIMAL},",
          "DEPENDENT_ID = #{dependentId,jdbcType=CHAR},",
          "EXPIRY_MONTH = #{expiryMonth,jdbcType=CHAR},",
          "EXPIRY_YEAR = #{expiryYear,jdbcType=CHAR},",
          "ISSUED_DATE = #{issuedDate,jdbcType=TIMESTAMP},",
          "MEMBER_ID = #{memberId,jdbcType=CHAR},",
          "MODIFIED_DATE = #{modifiedDate,jdbcType=OTHER},",
          "MODIFIED_TIME = #{modifiedTime,jdbcType=CHAR},",
          "PAYOR_CODE = #{payorCode,jdbcType=CHAR},",
          "POLICY_NO = #{policyNo,jdbcType=VARCHAR},",
          "NEW_IC = #{newIc,jdbcType=VARCHAR},",
          "EMP_NAME = #{empName,jdbcType=VARCHAR},",
          "DATE_OF_BIRTH = #{dateOfBirth,jdbcType=TIMESTAMP},",
          "GENDER = #{gender,jdbcType=CHAR},",
          "CORP_CODE = #{corpCode,jdbcType=VARCHAR},",
          "CHIP_LASTUPD = #{chipLastupd,jdbcType=TIMESTAMP},",
          "PLAN_CODE = #{planCode,jdbcType=VARCHAR},",
          "ENGLISH_NAME = #{englishName,jdbcType=VARCHAR},",
          "CARD_TYPE = #{cardType,jdbcType=CHAR},",
          "MASTER_POLICY_NO = #{masterPolicyNo,jdbcType=VARCHAR},",
          "MEMBER_CONTROL_NO = #{memberControlNo,jdbcType=VARCHAR}",
        "where CARD_NO = #{cardNo,jdbcType=DECIMAL}",
          "and RECORD_TYPE = #{recordType,jdbcType=CHAR}"
    })
    int updateByPrimaryKey(Card record);
}